package com.ztgf.order.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.order.mapper.OrderCommodityStatisticsMapper;
import com.ztgf.order.models.bo.OrderShopStatisticsBO;
import com.ztgf.order.models.bo.OrderStatisticsBO;
import com.ztgf.order.models.service.IOrderCommodityStatisticsService;
import com.ztgf.order.models.vo.OrderCommodityStatisticsShopVO;
import com.ztgf.order.models.vo.OrderCommodityStatisticsVO;
import com.ztgf.order.models.vo.OrderSalesCategoryShopVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Comparator;
import java.util.List;

import static com.ztgf.common.utils.UtilConstants.ONE;
import static com.ztgf.common.utils.UtilConstants.isNull;

/**
 * author: chenyu.wang
 * date: 2020-07-24 15:16
 * Description:
 */
@DubboService
public class OrderCommodityStatisticsServiceImpl implements IOrderCommodityStatisticsService {

    @Autowired
    private OrderCommodityStatisticsMapper orderCommodityStatisticsMapper;

    @Override
    public Integer queryCommodityTotal() {
        return orderCommodityStatisticsMapper.queryCommodityTotal();
    }

    @Override
    public Page<OrderCommodityStatisticsVO> queryCategoryGoods(OrderStatisticsBO bo) {
        Page<OrderCommodityStatisticsVO> page = new Page<>(bo.getPageNo(), bo.getPageSize());
        List<OrderCommodityStatisticsVO> list = orderCommodityStatisticsMapper.queryAllFianlCategory(page);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<OrderCommodityStatisticsShopVO> numberOfProductsInStoreCategory(OrderShopStatisticsBO bo) {
        Page<OrderCommodityStatisticsShopVO> page = new Page<>(bo.getPageNo(), bo.getPageSize());
        List<OrderCommodityStatisticsShopVO> list = orderCommodityStatisticsMapper.queryCategoryShopGoodsCount(page, bo);
        page.setRecords(list);
        return page;
    }
}
